// Triangle.hpp
#ifndef _TRIANGLE_HPP_
#define _TRIANGLE_HPP_
#include <cmath>
#include <iostream>
using namespace std;
//Triangle类的定义
class Triangle {
public:
  //设置三条边的值，若不能构成三角形，返回false
  bool Setabc(double x, double y, double z);
  //计算三角形的周长
  double Perimeter();
  //计算并返回三角形的面积
  double Area();

private:
  //三条边的长度为私有数据成员
  double a, b, c;
};

bool Triangle::Setabc(double x, double y, double z) {
  if ((x + y <= z) || (x + z <= y) || (y + z <= x)) {
    return false;
  }
  this->a = x;
  this->b = y;
  this->c = z;
  return true;
}

double Triangle::Perimeter() { 
  return this->a + this->b + this->c; 
}

double Triangle::Area() {//计算并返回三角形的面积
  double p = Perimeter() / 2;
  // cout << p << endl;
  return sqrt(p * (p - a) * (p - b) * (p - c));
} 
#endif